Make the args a flexible array inside the struct, and allocate them
authorMatthias Clasen <mclasen@redhat.com>
Wed, 28 Dec 2005 04:09:18 +0000 (04:09 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Wed, 28 Dec 2005 04:09:18 +0000 (04:09 +0000)
2005-12-27  Matthias Clasen  <mclasen@redhat.com>

* gtk/gtkbindings.h (GtkBindingSignal):
* gtk/gtkbindings.c (binding_signal_new): Make the
args a flexible array inside the struct, and allocate them
together.

ChangeLog
ChangeLog.pre-2-10
gtk/gtkbindings.c
gtk/gtkbindings.h

index 1c90179d15f2ce1d430569098dbcc3ed012256ca..1d4dcff26f44e60204336436f7c19d6b3e62206b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2005-12-27  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkbindings.h (GtkBindingSignal): 
+       * gtk/gtkbindings.c (binding_signal_new): Make the
+       args a flexible array inside the struct, and allocate them
+       together.
+
 Wed Dec 28 00:45:46 2005  Tim Janik  <timj@gtk.org>
 
        * gtk/gtkctree.c (row_delete): delete GtkCTreeRow as GtkCTreeRow, not
index 1c90179d15f2ce1d430569098dbcc3ed012256ca..1d4dcff26f44e60204336436f7c19d6b3e62206b 100644 (file)
@@ -1,3 +1,10 @@
+2005-12-27  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkbindings.h (GtkBindingSignal): 
+       * gtk/gtkbindings.c (binding_signal_new): Make the
+       args a flexible array inside the struct, and allocate them
+       together.
+
 Wed Dec 28 00:45:46 2005  Tim Janik  <timj@gtk.org>
 
        * gtk/gtkctree.c (row_delete): delete GtkCTreeRow as GtkCTreeRow, not
index 1aa26eb8d045879c6d673b65ec56a1597c3bb372..a6afdc8e90dd682e2a04704c5ed4f7c03d0ca55d 100644 (file)
@@ -65,11 +65,10 @@ binding_signal_new (const gchar *signal_name,
 {
   GtkBindingSignal *signal;
   
-  signal = g_new (GtkBindingSignal, 1);
+  signal = (GtkBindingSignal *) g_malloc0 (sizeof (GtkBindingSignal) + (n_args - 1) * sizeof (GtkBindingArg));
   signal->next = NULL;
-  signal->signal_name = g_intern_string (signal_name);
+  signal->signal_name = (gchar *)g_intern_string (signal_name);
   signal->n_args = n_args;
-  signal->args = g_new0 (GtkBindingArg, n_args);
   
   return signal;
 }
@@ -84,7 +83,6 @@ binding_signal_free (GtkBindingSignal *sig)
       if (G_TYPE_FUNDAMENTAL (sig->args[i].arg_type) == G_TYPE_STRING)
        g_free (sig->args[i].d.string_data);
     }
-  g_free (sig->args);
   g_free (sig);
 }
 
index 8c479f9ce0b69e4f946ae537dae4ef7ab94f7360..debd6989b8fb2aa9765c0ca8e0dddfa64578b531 100644 (file)
@@ -74,14 +74,6 @@ struct _GtkBindingEntry
   GtkBindingSignal     *signals;
 };
 
-struct _GtkBindingSignal
-{
-  GtkBindingSignal     *next;
-  gchar                        *signal_name;
-  guint                         n_args;
-  GtkBindingArg                *args;
-};
-
 struct _GtkBindingArg
 {
   GType                 arg_type;
@@ -92,6 +84,13 @@ struct _GtkBindingArg
   } d;
 };
 
+struct _GtkBindingSignal
+{
+  GtkBindingSignal     *next;
+  gchar                *signal_name;
+  guint                         n_args;
+  GtkBindingArg                 args[1]; /* flexible array */
+};
 
 /* Application-level methods */